package com.ibeacon.controller;

import java.util.HashMap;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.ibeacon.service.IbeaconDeviceService;

import net.sf.json.JSONObject;

@Controller
public class DeleteDeviceFromGroupController {

	

	@Autowired
	IbeaconDeviceService ibeaconDeviceService;
	
	@RequestMapping("/deleteDeviceFromGroup")
	public String AddIbeaconGroup(ModelMap model ,HttpServletResponse response,HttpServletRequest request){
		
		HashMap<String, String>  pramMap = new HashMap<String, String>(); 
		
		String groupId = request.getParameter("group_id");
		if (groupId !=null &&!"".equals(groupId)){
			pramMap.put("groupId", groupId);
		}
		String deviceId = request.getParameter("device_id");
		if (deviceId !=null &&!"".equals(deviceId)){
			pramMap.put("deviceId", deviceId);
		}
		String uuid = request.getParameter("uuid");
		if (uuid !=null &&!"".equals(uuid)){
			pramMap.put("uuid", uuid);
		}
		String major = request.getParameter("major");
		if (major !=null &&!"".equals(major)){
			pramMap.put("major", major);
		}
		String minor = request.getParameter("minor");
		if (minor !=null &&!"".equals(minor)){
			pramMap.put("minor", minor);
		}
		
		JSONObject json	=  ibeaconDeviceService.deleteDeviceFromGroup(pramMap);
		 model.addAttribute("json", json);
		 return "managegroup/deleteDeviceFromGroup";
		
	}
	
	
	
	


}
